home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / ada / gnat1792.zip / gnat179b / examples / tef.adb < prev    next >
Text File  |  1994-05-13  |  1KB  |  45 lines

  1. --  tef.adb
  2. --  a simple test to use the non-generic elementary function package and call 
  3. --  the some trig functions. Similar to tgef.adb except here there is no 
  4. --  instantiation of GEF (Generic ELementary Functions).
  5.  
  6. with Ada.Numerics.Elementary_Functions;
  7. with Ada.Numerics; use Ada.Numerics;
  8. with Text_IO;
  9. procedure Tef is
  10.    C : Character;
  11.    Y : Float;
  12.    P : Integer;
  13.    subtype Line is String (1 .. 80);
  14.    Filler  : Line := (others => ' ');
  15.    Display : array (0 .. 21) of Line;
  16. begin
  17.    Text_IO.Set_Page_Length (Text_IO.Current_Output, 0);
  18.    Text_IO.Put_Line ("Display of Sin, Cos and Arctan graphs");
  19.    Text_IO.Put_Line ("Legend: Sin (O), Cos (X), Arctan (+)");
  20.  
  21.  
  22.    for I in Display'range loop
  23.       Display (I) := Filler;
  24.    end loop;
  25.  
  26.    Display (10) := (1 .. 80 => '-');
  27.  
  28.    for I in 1 .. 20 loop
  29.       Y := Elementary_Functions.Cos (Float (I) * Pi / 10.0);
  30.       P := Integer (10.0 * Y) + 10;
  31.       Display (P)(4 * I) := 'O';
  32.       Y := Elementary_Functions.Sin (Float (I) * Pi / 10.0);
  33.       P := Integer (10.0 * Y) + 10;
  34.       Display (P)(4 * I) := 'X';
  35.       Y := Elementary_Functions.Arctan (Float (I) * Pi / 10.0);
  36.       P := Integer (10.0 * Y) + 10;
  37.       Display (P)(4 * I) := '+';
  38.    end loop;
  39.  
  40.    for I in  Display'range loop
  41.       Text_IO.Put_Line (Display (I));
  42.    end loop;
  43.  
  44. end Tef;
  45.